﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 工厂模式
{


    class ShapeFactory
    {
        //使用 getShape 方法获取形状类型的对象
        public IShape getShape(FyType shapeType)
        {
            switch (shapeType)
            {
                case FyType.Rectangle:
                    return new Rectangle();
                case FyType.Square:
                    return new Square();
                case FyType.Circle:
                    return new Circle();
                default:
                    break;
            }

            return null;
        }

        public static Shape GetShape(FyType type)
        {
            Shape shape = null;
            switch (type)
            {
                case FyType.Undefined:
                    break;
                case FyType.Rectangle:shape = new Rectangle();
                    break;
                case FyType.Square:shape = new Square();
                    break;
                case FyType.Circle:shape = new Circle();
                    break;
                default:
                    break;
            }



            return  shape;
            ;


        }
    }
}
